#include<stdio.h>
void Swap(int* x, int* y)
{
	int tmp = *x;
	*x = *y;
	*y = tmp;
}
void Quicksort(int* arr, int left,int right)
{
	if (left >= right)
	{
		return;
	}
	int begin = left;
	int end = right;
	int cur = left + 1;
	int keyi = arr[left];
	while (cur <= end)
	{
		if (keyi > arr[cur])
		{
			Swap(&arr[cur], &arr[begin]);
			begin++;
			cur++;
		}
		else if (keyi < arr[cur])
		{
			Swap(&arr[cur], &arr[end]);
			end--;
		}
		else
		{
			cur++;
		}
	}
	Quicksort(arr, left, begin-1);
	Quicksort(arr, end+1, right);

}

int main()
{
	int arr[10] = { 1,3,4,5,9,8,7,2,6,0 };
	int n = 10;
	Quicksort(arr, 0, n-1);
	for (int i = 0; i < n; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}